<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>包装供应商-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../aaa/css/font.css">
    <link rel="stylesheet" href="../aaa/css/xadmin.css">
    <script src="../aaa/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../aaa/js/xadmin.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" action="/Distributor/page" method="post">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="distributorname"  placeholder="请输入供应商名称" autocomplete="off" class="layui-input" >
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="statusid" class="layui-input" >
                                <option value="0">请选择审核状态</option>
                                <option th:each="status1:${status1s}"
                                        th:value="${status1.statusid}"
                                        th:text="${status1.statusname}"
                                ></option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
                    <button class="layui-btn" onclick="xadmin.open('添加商品','/Distributor/goAdd',700,400)"><i class="layui-icon"></i>添加</button>
                    <button class="layui-btn" onclick="xadmin.open('添加商品','/Distributor/goPiliang',700,400)"><i class="layui-icon"></i>批量添加</button>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>
                                <input type="checkbox" class="checkAll" lay-filter="allChoose"  lay-skin="primary">
                            </th>
                            <th>id</th>
                            <th>分销商名字</th>
                            <th>分销商法人</th>
                            <th>资金</th>
                            <th>审核状态</th>
                            <th>分销商地址</th>
                            <th>编辑</th>
                        </thead>
                        <tbody>
                        <tr th:each="dis:${dis}">
                            <td>
                                <input type="checkbox" name="id[]" lay-filter="checkone"  th:value="${dis.distributorid}" lay-skin="primary">

                            </td>
                            <td th:text="${dis.distributorid}"></td>
                            <td th:text="${dis.distributorname}"></td>
                            <td th:text="${dis.distrlegal}"></td>
                            <td th:text="${dis.distrcapital}"></td>
                            <td th:text="${dis.statusl.statusname}"></td>
                            <td th:text="${dis.distloc}"></td>
                            <td>
                                <a>
                                    <a title="删除" th:onclick="member_del(this,'[(${dis.distributorid})]')">
                                        <i class="layui-icon">&#xe640;</i>
                                    </a>
                                    <a title="编辑" th:onclick="xadmin.open('修改用户','/Distributor/selectById?distributorid='+'[(${dis.distributorid})]',600,400)">
                                        <i class="layui-icon">&#xe642;</i>
                                    </a>
                                </a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div style="text-align: center">
                        <span th:text="'共'+(${pages})+'页'"></span>
                        <span th:text="'当前第'+(${pageNo}+'页')"> </span>
                        <a th:href="@{/Distributor/page(pageNo=1)}">首页</a>
                        <span th:if="${pageNo} !=1">
                            <a th:href="@{/Distributor/page(pageNo=${pageNo} - 1)}"> | 上一页</a>
                        </span>
                        <span th:if="${pageNo} !=${pages}">
                            <a th:href="@{/Distributor/page(pageNo=${pageNo} + 1)}">下一页 | </a>
                        </span>
                        <a th:href="@{/Distributor/page(pageNo=${pages})}">尾页</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;

        form.on('checkbox(allChoose)', function(data){
            if(data.elem.checked){
                $('tbody input').prop('checked',true);
            }else{
                $('tbody input').prop('checked',false);
            }
            form.render('checkbox');
        });
        //单选
        form.on('checkbox(checkone)', function (data) {
            var i = 0;
            var j = 0;
            $("input[name='id[]']").each(function () {
                if( this.checked === true )
                {
                    i++;
                }
                j++;
            });
            if( i == j )
            {
                $(".checkAll").prop("checked",true);
                form.render('checkbox');
            }else
            {
                $(".checkAll").removeAttr("checked");
                form.render('checkbox');
            }

        });

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

    /*用户-删除*/
    function member_del(obj,distributorid){
        layer.confirm('确认要删除吗？',function(){
            //发异步删除数据
            $.ajax({
                url: "/Distributor/DisDel?distributorid="+distributorid,
                type: "POST",
                success: function (result) {
                    window.location.reload();//重新页面
                }
            });
            // $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }

    function delAll () {
        var ids = new Array();
        num = $(":checkbox[name='id[]']:checked").length;
        if (num == 0) {
            alert('必须选中一行才可以删除！');
            return false;
        } else {
            $.each($(":checkbox[name='id[]']:checked"), function (i, v) {
                ids[i] = this.value;
            });
        }
        layer.confirm('确认要删除吗？',function() {
            $.ajax({
                url: '/Distributor/batchDel?ids'+ids,
                type: 'POST',
                data: {ids: ids},
                success: function (result) {
                    window.location.href='/Distributor/page'
                }
            });
            layer.msg('已删除!',{icon:1,time:1000});
        })
    }
</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();
</script>
</html>
